import Router from 'koa-router';
import uploadController from '../controllers/upload.controller';
import uploadService from '../services/upload.service';
import { authMiddleware } from '../middlewares/auth.middleware';

const router = new Router({
  prefix: '/api/upload',
});

// 上传单个图片
router.post(
  '/image',
  authMiddleware,
  uploadService.getImageUploadMiddleware().single('image'),
  uploadController.uploadImage
);

// 上传多个图片
router.post(
  '/images',
  authMiddleware,
  uploadService.getImageUploadMiddleware().array('images', 10),
  uploadController.uploadMultipleFiles
);

// 上传单个文件
router.post(
  '/file',
  authMiddleware,
  uploadService.getFileUploadMiddleware().single('file'),
  uploadController.uploadFile
);

// 上传多个文件
router.post(
  '/files',
  authMiddleware,
  uploadService.getFileUploadMiddleware().array('files', 10),
  uploadController.uploadMultipleFiles
);

// 删除文件
router.delete(
  '/',
  authMiddleware,
  uploadController.deleteFile
);

export default router;
